#include "TesPch.h"
#include "TesTokenStream.h"


TesTokenStream::TesTokenStream( const list<TesToken> & tokens )
: mTokens( tokens )
{
	mCurrent = mTokens.begin();
}


bool TesTokenStream::IsEndOfStream() const
{
	return mCurrent == mTokens.end();
}


const TesToken & TesTokenStream::Peek( int count ) const
{
	list<TesToken>::const_iterator it = mCurrent;
	advance( it, count );
	return *it;
}


int TesTokenStream::SearchForward( TesTokenType type ) const
{
	int curIndex = 0;
	for( list<TesToken>::const_iterator it = mCurrent; it != mTokens.end(); ++it )
	{
		if( it->Type == type )
		{
			return curIndex;
		}
		curIndex++;
	}
	return -1;
}